import datetime
import formencode


class Feedback(object):
  """ A comment that a user posted about one page.
  """
  
  def __init__(self, url, comment, user, now=None):
    """
    Arguments:
      - url: string, url of the commented page.
      - comment: unicode, the comment itself.
      - user: User object, who posted the comment?
      - now: datetime - optional, when are we?
    """
    self.date = now or datetime.datetime.now()
    self.url = url
    self.comment = comment
    self.user = user
    

class FeedbackValidator(formencode.Schema):
  """Validate a feedback.
  """
  allow_extra_fields = True
  filter_extra_fields = False
  url = formencode.validators.String(not_empty=True) # eventually use URL
  comment = formencode.validators.String(not_empty=True)
  